package com.example.weizix.ui.fragment;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.weizix.R;
import com.example.weizix.base.BaseLazyLoadFragment;
import com.example.weizix.bean.DailyNewsBean;
import com.example.weizix.presenter.DailyNewsPresenter;
import com.example.weizix.ui.adapter.RlvDailyNewsAdapter;
import com.example.weizix.view.DailyNews;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * A simple {@link Fragment} subclass.
 */
public class DailyNewsFragment extends BaseLazyLoadFragment<DailyNewsPresenter> implements DailyNews {

    @BindView(R.id.rlv)
    RecyclerView mRlv;
    @BindView(R.id.fab)
    FloatingActionButton mFab;
    private RlvDailyNewsAdapter mAdapter;

    /**
     *
     * @return
     */
    public static DailyNewsFragment getInstance(){
        DailyNewsFragment fragment = new DailyNewsFragment();
        return fragment;
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {
        mPresenter.getLastesNews();
    }

    @Override
    protected DailyNewsPresenter initPresenter() {
        return new DailyNewsPresenter();
    }

    @Override
    protected void initView(View view) {
        mRlv.setLayoutManager(new LinearLayoutManager(getContext()));
        ArrayList<DailyNewsBean.TopStoriesBean> bannerList = new ArrayList<>();
        ArrayList<DailyNewsBean.StoriesBean> newsList = new ArrayList<>();
        mAdapter = new RlvDailyNewsAdapter(getContext(), bannerList, newsList);
        mRlv.setAdapter(mAdapter);
    }

    @Override
    protected int getLayout() {
        return R.layout.fragment_daily_news;
    }


    @OnClick(R.id.fab)
    public void click(View v){
        switch (v.getId()) {
            case R.id.fab:
                break;
        }
    }

    @Override
    public void setData(DailyNewsBean dailyNewsBean) {
        mAdapter.setData(dailyNewsBean);
    }
}
